<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<%@include file="../common/selfCss.jsp"%>
<script type="text/javascript">
	$(function(){
		$("#add_channel_form").validate({
			success : function(label) {
				label.text("").addClass("validate_success");
			},
			rules : {
				name : {
					required : true,
					minlength : 2,
					maxlength : 20
				}
			},
			messages : {
				name : {
					required : "请输入频道名称",
					minlength : "请填写2个以上字",
					maxlength : "请填写20个以下的字"
				}
				
			
			},
			submitHandler : function() {
				
				$.post("/misc/index/insertChannel.htm", {
					name : $("#name").val(),
					mark :$("#mark").val(),
					parent:$("#parent").val(),
					deep:1
					
				},function(data){
					if(data=="success"){
						parent.indexGrid.loadData();
						alert("添加成功！");
					}
					if(data=="error"){
						$.ligerDialog.warn("系统有点抽经，请稍候重试！");
					}
				});
			}
		});
	});
	function updateChannel(id){
		$.post("/misc/index/updateChannel.htm", {
			name : $("#name").val(),
			mark :$("#mark").val(),
			identifier:id
		},function(data){
			if(data=="success"){
				parent.indexGrid.loadData();
				alert("更新成功！");
			}
			if(data=="error"){
				$.ligerDialog.warn("系统有点抽经，请稍候重试！");
			}
		});
	}
</script>
			
	<form method="post" id="add_channel_form" action="">
		<table width="50%" class="def_t">
			<tr>
				<td > 频道名称：</td>
				<td ><input type="text" id="name" name="name" value="${channel.name }"/></td>
			</tr>
			<tr>
				<td > mark：</td>
				<td ><input type="text" id="mark" name="mark" value="${channel.mark }"/>
					<input type="hidden" id="parent" name="parent" value="${parent}"/>
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<c:choose>
						<c:when test="${ empty channel}"><button type="submit" >确定</button></c:when>
						<c:otherwise>
							<input type="button" onclick="updateChannel('${channel.identifier}');" value="更新"/>
						</c:otherwise>
					</c:choose>
				</td>
			</tr>
		</table>
</form>
